- LeetCode 704

Iterative solution: Time O(log2(n)) and space O(1)
Recursive solution: Time O(log2(n)) and space O(log2(n))

- LeetCode 125

Palindrome - Iteratively (O(n), O(1)); and recursively (O(n), O(n))

- Algorithm analysis

How to measure the performance of an algorithm?

Two metrics: 1) Time complexity; 2) Space complexity

Our aim: General dependenc of running time on the size of the input

Option#1: Experimental analysis of the algorithms

Limitations: 
- Experiments can be performed only on a finite set of inputs
- Compare the running time of algorithm A to algorithm ; experiments must be 
done in the same software and hardware environment
- Time consuming: having to implement the algorithm

To define a way to analyze the running time of an algorithm: 
- Take all inputs into account
- Compare algorithm A to algorithm B in a way that would be independent of software
and hardware environments
- Base the analysis on a high-level description of the solution (pseudo-code)

Solution: Big-Oh notation

- To analyze the running time => counting the number of primitive operations involved in the solution
Examples include: a) arithmetic operation; b) comparing one variable to another; c) indexing into
an array; d) calling a method

# of primitive operations correlates well with running time of the algorithm

- Best case scenario; - Average case scenario; - Worst case scenario


























